-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request color presentations when clicking on a color box #2065
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rchl
reviewed
Sep 23, 2022
rchl
approved these changes
Sep 23, 2022
predragnikolic
approved these changes
Sep 25, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from #2065 (comment)
Everything else looks good.
rchl
added a commit
that referenced
this pull request
Sep 27, 2022
* main: Fix issues with diagnostics panel toggling on save (#2063) Request color presentations when clicking on a color box (#2065) Import new imports like NotRequired from "typing" Ensure "Source Actions..." request includes the "source" kind (#2064) refactor(types): Mark properties with NotRequired (#2062) Add template variable `$text_document_position` in execute command (#2061) Only update content of diagnostics panel when visible (#2054) Remove Range class and rename RangeLsp to Range (#2058)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This runs the
textDocument/colorPresentation
request when clicking on a color box, and shows the results in a quick panel. I think it is better to apply the change into the file only after selecting one of the quick panel entries, rather than immediately like it's implemented in the VSCode color picker when cycling through the different color formats. Because the conversion from RGB to HSL/HWB and back again might alter the original color (e.g.#dddddd
->hsl(0, 0%, 87%)
->hwb(0 87% 13%)
->rgb(222, 222, 222)
->#dedede
).There is no special server capability for this request by the way, so we can't decide beforehand whether or not it is supported by the server and is useful to make the color box clickable. (But maybe it's expected that servers that have the colorProvider capability, which is used for
textDocument/documentColor
, should also support colorPresentation.)And there can be optional "additionalTextEdits" in the response, which are ignored in this PR. I don't really know what should be the use of those; maybe it's to replace all occurencies of the particular color. But that seems rather dangerous or unexpected for the user to me, so I guess it's better to leave this out for now.
Note that you can observe two color boxes for a very short amount of time after selecting a quick panel entry, but this seems unrelated to this pull request. It's probably some kind of bug in the code how the color box phantoms are updated, or in the lsp_apply_document_edit command (or in how these two situations work together).
And in case a minihtml color picker gets implemented at a later point, this functionality could be adjusted with minimal changes to be invoked from a link in the color picker.